package leetcode.editor.cn;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Administrator
 * @description 力扣1234
 * @date 2023/3/12 0012
 */
public class Solution1234 {

    public static void main(String[] args) {
        Solution1234 solution1234 = new Solution1234();
        solution1234.balancedString("WWEQERQWQWWRWWERQWEQ");
    }

    public int balancedString(String s) {
        Map<Character, Integer> map = new HashMap<>();
        for (char c : s.toCharArray()) {
            map.put(c, 1 + map.getOrDefault(c, 0));

        }
        int num = 0, len = s.length()/4;
        for (Integer value : map.values()) {
            if (len<value){
                num += value-len;
            }
        }
        return num;
    }

}
